package ch.webkito.example;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.inject.Singleton;

import ch.webkito.i18n.I18n;
import ch.webkito.servlet.InitParam;
import ch.webkito.servlet.ServletConfiguration;
import ch.webkito.servlet.WebkitoServlet;
import ch.webkito.template.Partial;
import ch.webkito.template.Partials;
import ch.webkito.template.Template;

@Singleton
@I18n({"translations"})
@Template("main")
@Partials({@Partial(name="header", partial="header"), @Partial(name="footer", partial="footer")})
@ServletConfiguration(urlMappings = {"/index.html"}, initParams = {@InitParam(name="webkito", value="WEBKITO")})
public class HomeServlet extends WebkitoServlet {
	private static final long serialVersionUID = 1L;
	
	@Override
	public void doGet(HttpServletRequest request, HttpServletResponse response) {
		final Map<String, Object> params = new HashMap<String, Object>();
		params.put("webkito", getInitParameter("webkito"));
		params.put("user", "Spreiti");
		
		try {
			autoRender(request, response, params);
		} catch (IOException e) { ; }
	}
}
